<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>使用 DOM 方法创建 HTML 元素和文本</title>
</head>
<body>
<script>
    var newText = document.createTextNode('My Heading');
    var newElem = document.createElement('h1');

    newElem.appendChild(newText);
    document.body.appendChild(newElem);

    newText = document.createTextNode('This is some text in a paragraph');
    newElem = document.createElement('p');
    newElem.appendChild(newText);
    document.body.appendChild(newElem);
</script>
</body>
</html>